package com.ems.controller.supers.action;

import com.ems.pojo.data.ResultData;
import com.ems.pojo.data.RetunResult;
import com.ems.pojo.permission.GroupAction;
import com.ems.service.supers.action.GroupActionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: 伟伟
 * @Date: 2019/10/5
 * @Description: 角色与权限关系类
 * @Version: 1.0
 */
@Controller
@CrossOrigin //允许所有ip跨域
@RequestMapping("/groupActionController")
public class groupActionController {
    @Autowired
    @Qualifier("groupActionService")
    private GroupActionService groupActionService;


    /**
     * 为角色添加权限
     */
    @ResponseBody
    @RequestMapping("/addGroupAction")
    public ResultData addGroupAction(@RequestBody GroupAction groupAction){
        if(groupActionService.addGroupAction(groupAction) > 0){
            return RetunResult.AssemblyData();
        }
        return RetunResult.AssemblyData("failure.to.add.groupAction");
    }

    /**
     * 为指定角色删除权限
     */
    @ResponseBody
    @RequestMapping("/deleteGroupAction")
    public ResultData deleteGroupAction(@RequestBody GroupAction groupAction){
        groupActionService.deleteGroupAction(groupAction);
        return RetunResult.AssemblyData();
    }


}
